//
//  BTTopicDetailHeader.m
//  BaxTer
//
//  Created by wsj2015 on 16/9/7.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#import "BTTopicDetailHeader.h"
#import "Masonry.h"
#import "UIImageView+BTImageView.h"

@implementation BTTopicDetailHeader

- (void)awakeFromNib{
    
    CGFloat f = kScreenFactor;
//    [self.icon mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.height.mas_equalTo(f * 160);
//    }];

    self.iconHeight.constant = 220 *f;
    self.icon.image = [UIImage imageNamed:@"5.jpg"];
    [super awakeFromNib];
    
}

+ (instancetype)detailheader{
  
    return [[NSBundle mainBundle
             ] loadNibNamed:@"BTTopicDetailHeader" owner:nil options:0].lastObject;

}
- (IBAction)priseAction:(UIButton *)sender {

    self.priseBlock(sender);
    
}
- (IBAction)collectAction:(UIButton *)sender {
    
    self.collectBlock(sender);
    
}
- (void)setModel:(BTTopicDetailModel *)model{
    _model = model;
    //"topicname": "2",
    //"topicdesc": "22",
    //"topicImage": "http://cdn.duitang.com/uploads/blog/201307/07/20130707135905_YMdUe.thumb.200_0.jpeg",
    //"createDate": 1473241385000,
    //"updateDate": 1473317747000,
    //"status": 1,
    //"uploadUser": 1,
    //"topicclickcount": 12,
    //"topiclikecount": 0,
    //"topiccollectcount": 0,
    //"islike": null,
    //"iscollect": null,
    //"topicStatus": null,
    self.topicL.text = model.topicname;
    [self.icon bt_setImageWithUrl:model.topicImage];
    
    self.priseBtn.selected = [model.islike boolValue] ? YES:NO;
    self.collectBtn.selected =[model.iscollect boolValue] ? YES:NO;
    
    [self.priseBtn setTitle:[NSString stringWithFormat:@"%@",model.topiclikecount] forState:UIControlStateNormal];
    [self.collectBtn setTitle:[NSString stringWithFormat:@"%@",model.topiccollectcount] forState:UIControlStateNormal ];
    
    
}

@end
